﻿@using EasyWeb.Configuration
@model EWNavigationNodeCollection
@{
    ViewBag.Title = "Dashboard";
}
@functions {
    string NormalizeUrl(string url)
    {
        if (!string.IsNullOrEmpty(url) && url.StartsWith("~/", true, CultureInfo.InvariantCulture))
        {
            return Url.Content(url);
        }

        return url;
    }
}

<div class="easyweb-page-admin">
    @for (var i = 0; i < this.Model.Count; ++i)
    {
        var first = default(EWNavigationNode);
        var second = default(EWNavigationNode);

        first = this.Model[i];

        ++i;
        if (i < this.Model.Count)
        {
            second = this.Model[i];
        }

        <div class="row">
            @if (first != null)
            {
                <div class="col-sm-6">
                    <h2><i class="@first.Icon"></i> @first.DisplayName</h2>
                    <ul class="list-unstyled">
                        @foreach (var child in first.Nodes)
                        {
                            <li><a href="@NormalizeUrl(child.Url)"><i class="@child.Icon"></i> @child.DisplayName</a></li>
                        }
                    </ul>
                </div>
            }
            @if (second != null)
            {
                <div class="col-sm-6">
                    <h2><i class="@second.Icon"></i> @second.DisplayName</h2>
                    <ul class="list-unstyled">
                        @foreach (var child in second.Nodes)
                        {
                            <li><a href="@NormalizeUrl(child.Url)"><i class="@child.Icon"></i> @child.DisplayName</a></li>
                        }
                    </ul>
                </div>
            }
        </div>
    }
</div>